<template>
  <el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" title="查看核销卡下级" width="700px">
    <el-card>

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
              <el-table-column type="selection" width="55" />
              <el-table-column v-if="columns.visible('id')" prop="id" label="id" />
              <el-table-column v-if="columns.visible('name')" prop="name" label="核销卡名称" />
              <el-table-column v-if="columns.visible('num')" prop="num" label="数量" />
              <el-table-column v-if="columns.visible('cardNum')" prop="cardNum" label="核销卡编号" />
            </el-table>
            <!--分页组件-->
            <pagination />
    </el-card>
  </el-dialog>
</template>

<script>
import crudYxStoreWriteCard from '@/api/yxStoreWriteCard'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import { parseTime } from '@/utils/index'
import pagination from '@crud/Pagination'
import crudOperation from '@crud/CRUD.operation'
import rrOperation from '@crud/RR.operation'
import MaterialList from "@/components/material";
import udOperation from '@crud/UD.operation'
// crud交由presenter持有
const defaultCrud = CRUD({ title: 'card', url: 'api/yxStoreWriteCard', sort: 'id,desc', crudMethod: { ...crudYxStoreWriteCard }})
const defaultForm = { id: null, name: null, productId: null, num: null, cardNum: null, cardPassword: null }

export default {
  props: {
    // isAdd: {
    //   type: Boolean,
    //   required: true
    // }
  },
  name: 'Card',
  components: { pagination, crudOperation, rrOperation, udOperation ,MaterialList},
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  data() {
    return {
      loading: false, dialog: false, expressInfo: [],
      activeName: "first",
      tableData: [],
      form: {
        uid: '',
        nickname: ''
      },
      rules: {
        unique: [
          { required: true, message: 'please enter', trigger: 'blur' }
        ]
      }
    }
  },
  mounted() {
   // this.express()
  },
  methods: {
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
      productList().then(res => {
        this.productDataList = res;
      })
    },
    handleClick(tab, event) {
      this.spread(this.form.uid)
    },
    parseTime,
    cancel() {
      this.dialog = false
    },
    spread(id) {
      this.url = 'api/yxStoreWriteCard'
      const sort = 'id,desc'
      this.params = {
        page: this.page,
        size: this.size,
        mainId: id
      }
      const query = this.query
      const type = query.type
      const value = query.value
      if (type && value) { this.params[type] = value }
      return true
      console.log(id)
    }
  }
}
</script>

<style scoped>
  .text {
    font-size: 12px;
  }

  .item {
    padding: 6px 0;
  }

</style>
